#pragma once
#include <cstdio>
#include <unistd.h>
#include"TcpClient.h"
#include"InetAddress.h"
#include"ThreadSafeQueue.h"

namespace wjc {
    class ChatClient {
    private:
        TcpClient client;
        ThreadSafeQueue<std::string> queueOut;

        void onMessage(TcpClient& client, const ConnectionPtr& conn, BufferPtr& buff, Timestamp tm);

        void onConnection(TcpClient& client, const ConnectionPtr& conn);

    public:
        ChatClient(const net::InetAddress& serverAddr, const std::string& name);

        void start();

        ThreadSafeQueue<std::string>& getQueueOut() { return queueOut; }
    };
}
